#include <limits.h>

#ifndef _COMMON_H
#define _COMMON_H

#define CHECK_OPEN_FORWRITE 1
#define CHECK_FOR_MIMETYPE 2
#define CHECK_FOR_SYMLINK 3
#define CHECK_FOR_ALLOWED_SYSCALL 4
#define CHECK_FOR_CGI 5
#define CHECK_FOR_DIRECTORY_TRAVERSAL 6
#define CHECK_FOR_ALLOWED_PORTS 7

#define CHECK_FILE_CREATION_UNOWNED 8
#define CHECK_FILE_OVERWRITE_UNOWNED 9
#define CHECK_FILE_RENAME_UNOWNED 10
#define CHECK_FILE_CREATION_SYS_DIR 11
#define CHECK_FILE_OVERWRITE_SYS_DIR 12
#define CHECK_PRIVILEGE_EXEC 13
#define CHECK_NETWORK_ACCESS 14
#define CHECK_FILE_WRITE_UID 15
#define CHECK_FILE_WRITE_GID 16

#define NO_OF_ALLOWED_SYSCALLS 51
/* Functions defined in controller.c */

struct syscall_args
{
	char path[PATH_MAX];
	char target[PATH_MAX];
	int flags;
	int flags1;
};

int main_controller(int syscall_no, char *appln_name,struct syscall_args args,pid_t pid);

/*Functions defined in policy_checker.c */

int check_open_for_write();

int check_for_file_type(char *filename);

int check_for_symlinks(char *path);

int check_for_allowed_syscalls(int syscall_no, int *allowed_list);

int check_for_cgi(char *path);

int check_if_owned(char *path,char *appname);

int check_for_file_creation(char *path, char *appname);

void get_parent_dir(char *path, char *dest);

void follow_path(char *orig,char *newpath);

int check_for_overwrite(char *path,char *appname);

int check_for_rename_unowned(char *path, char *appname);

int check_if_sysdir(char *path);

int check_for_sysdir(char *path);

int check_file_write_uid(char *path,pid_t pid);

int check_file_write_gid(char *path,pid_t pid);

int check_for_directory_traversal(char *path,pid_t pid);

int path_traversal(char path[], int gid);
#endif
